<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
<script>
    var arr = [{
        name: 'jack',
        age: 25
    }, {
        name: 'marry',
        age: 21
    }, {
        name: 'ben',
        age: 23
    }]

    var flag = false
    var obj = {
        operation: 'add'
    }
    if (flag == true) {
        obj = {
            operation: 'edit'
        }
    }
    console.log(obj)
    console.log({
        ...this.arr[0],
        ...obj
    })

    // 主要用途 克隆
</script>
</body>

</html>
